package api

import (
	"context"
	"github.com/labstack/echo/v4"
	"net/http"
	"week4/pkg/app"
)

type ApiServer struct {
	e *echo.Echo
}

func NewApiServer() app.Server {
	e := echo.New()
	e.GET("/", func(c echo.Context) error {
		return c.String(http.StatusOK, "Hello, World!")
	})
	return &ApiServer{
		e: e,
	}
}

func (a *ApiServer) Start(ctx context.Context) error {
	return a.e.Start("0.0.0.0:1324")
}

func (a *ApiServer) Stop(ctx context.Context) error {
	return a.e.Shutdown(ctx)
}
